package com.room.service;

import com.room.mapper.AnnounMapper;
import com.room.pojo.Announ;
import com.room.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建人 lin
 * @创建时间 2019/10/5
 * @描述
 */
@Service
public class AnnounService {


    @Autowired
    AnnounMapper announMapper;

    //插入公告
    public int insertAnnoun(Announ announ){
        return announMapper.insert(announ);
    }

    //根据分页数据获取所有公告
    public List<Announ> getAnnounByPage(Integer page, Integer size){
        int start = (page-1) * size;
        return announMapper.getAnnounByPage(start,size);
    }

    //获取公告总数
    public Long getAnnounCount(){
        return announMapper.getAnnounCount();
    }

    //修改信息
    public int updateAnnoun(Announ announ){
        return announMapper.updateAnnoun(announ);
    }

    //通过指定id删除公告
    public boolean deleteAnnounById(String ids){
        String[] split = ids.split(",");
        return announMapper.deleteAnnounById(split) == split.length;
    }
}
